<template>
    <div class="give-up" @click="giveUp">
        <span class="iconfont icon-x-copy"></span>
        放弃订单
    </div>
</template>

<script>
import { MessageBox } from 'mint-ui'
import { Toast } from 'mint-ui'
import {giveupOrderByPaishou} from "../api/api";

export default {
    methods: {
        giveUp() {
          //放弃订单，发送一个请求，后台 撤消当前拍手的接单
            MessageBox.confirm('确定放弃此订单?').then(action => {
                giveupOrderByPaishou(this.$root.openId,this.$root.orderNum).then(res => {
                  Toast({
                    message: res.message,
                    duration: 1500
                  });
                  if(res.success){
                    setTimeout(function () {
                      WeixinJSBridge.call('closeWindow')
                    },1400)
                  }
                })

            })
        }
    }
}
</script>

<style lang="scss" scoped>
.give-up {
    font-size: 1.2rem;
    position: fixed;
    right: 0;
    top: 0.5rem;
    color: #fff;
    background-color: #da5360;
    padding: 0.5rem 1rem;
    border-top-left-radius: 0.5rem;
    border-bottom-left-radius: 0.5rem;

    span {
        vertical-align: middle;
    }
}
</style>
